package com.bjpowernode;

import com.bjpowernode.service.StudentService;
import com.bjpowernode.service.impl.StudentServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringTest01 {
    public static void main(String[] args) {
        //以前的方式，自己去new
/*        StudentService studentService = new StudentServiceImpl();
        studentService.study();*/

        //使用spring创建对象,spring容器
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

        //找spring获取StudentService对象,这里的字符串要跟配置文件中的bean里面的id一致
        StudentService studentService1 = (StudentService)context.getBean("studentService");

        StudentService studentService2 = (StudentService)context.getBean("studentService");

        //关闭容器
        context.close();
    }
}
